#!/usr/bin/python3
# -*- coding: utf-8 -*-

import numpy  as np
import pandas as pd
import talib as ta

eps = 1e-8

def signal(*args):
    # Lcsd 指标
    df = args[0]
    n = args[1]
    factor_name = args[2]

    df['median'] = df['close'].rolling(n).mean()
    df[factor_name] = (df['low'] - df['median']) / (df['low'] + eps)

    # 删除多余列
    del df['median']

    return df
